package com.example.rabbitmq.example.rabbitmq.route;

import com.rabbitmq.client.*;

import java.io.IOException;

public class ErrorConsumer {

    public static void main(String[] args) throws Exception {
        ConnectionFactory factory = new  ConnectionFactory();
        factory.setUri("amqp://admin:admin@192.168.1.3:5672/%2f");
        final Connection connection = factory.newConnection();
        final Channel channel = connection.createChannel();
        channel.exchangeDeclare("exchange_route", "direct", false, false, null);
        channel.queueDeclare("error", false,false, false, null );
        channel.queueBind("error","exchange_route", "ERROR");
        channel.basicConsume("error", new DeliverCallback() {
            @Override
            public void handle(String consumerTag, Delivery message) throws IOException {
                System.out.println("error::"+ new String(message.getBody()));
            }
        }, consumerTag -> { });

    }
}
